package poo.util;

import java.util.Scanner;

public class MatriciUtils {

	static Scanner sc = new Scanner(System.in);
	
	public static int[][] newMatrice(){
		System.out.print("Dimensione del sistema m x n = ");
		int m = sc.nextInt();
		int n = sc.nextInt();
		
		int[][]matrice=new int[m][n];
		for(int i=0; i<matrice.length; i++)
			for(int j=0; j<matrice[0].length; j++){
				System.out.println("Fornisci "+m+" x "+n+" elementi della matrice a per righe");
				System.out.print("a["+i+","+j+"]=");
				matrice[i][j]=sc.nextInt();
				}
		return matrice;
		
	}
	
	/*public static double[][] newMatriceDouble(){
		System.out.print("Dimensione del sistema m x n = ");
		double m =sc.nextDouble();
		double n =sc.nextDouble();
		double[][]matrice=new double[m][n];
		
		for(int i=0; i<matrice.length; i++)
			for(int j=0; j<matrice[0].length; j++){
				System.out.println("Fornisci "+m+" x "+n+" elementi della matrice a per righe");
				System.out.print("a["+i+","+j+"]=");
				matrice[i][j]=sc.nextDouble();
				}
		return matrice;
	}
	*/
	public static void stampaMatrice(int[][]m){
		for(int i=0; i<m.length; i++){
			for(int j=0; j<m[0].length; j++)
				System.out.printf("%5d", m[i][j]);
			System.out.println();	
			}
		
	}
	public static void stampaMatrice(double
			[][]m){
		for(int i=0; i<m.length; i++){
			for(int j=0; j<m[0].length; j++)
				System.out.printf("%5d", m[i][j]);
			System.out.println();	
			}
		
	}
	
	public static void main(String[] args) {
		
		//double[][]m=MatriciUtils.newMatriceDouble();
		//MatriciUtils.stampaMatrice(m);
	
		int[][]m=MatriciUtils.newMatrice();
		MatriciUtils.stampaMatrice(m);
	}

}
